

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>SuperTiled2Unity 1.0.0.0 documentation</title>
  

  
  
  
  

  
  <script type="text/javascript" src="_static/js/modernizr.min.js"></script>
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
        <script type="text/javascript" src="_static/jquery.js"></script>
        <script type="text/javascript" src="_static/underscore.js"></script>
        <script type="text/javascript" src="_static/doctools.js"></script>
        <script type="text/javascript" src="_static/language_data.js"></script>
    
    <script type="text/javascript" src="_static/js/theme.js"></script>

    

  
  <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="_static/theme_overrides.css" type="text/css" />
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="index.html#document-index">
          

          
            
            <img src="_static/docs_logo.png" class="logo" alt="Logo"/>
          
          </a>

          
            
            
            
              <div class="version">
                latest
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
            
              <!-- Local TOC -->
              <div class="local-toc"><p class="caption"><span class="caption-text">User Manual</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-manual/sorting">Sorting with SuperTile2Unity</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#how-supertiled2unity-implements-sorting">How SuperTiled2Unity Implements Sorting</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#tile-objects-and-sorting">Tile Objects and Sorting</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#dynamic-sorting-with-a-custom-sort-axis">Dynamic Sorting with a Custom Sort Axis</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-manual/custom-properties">Custom Properties Support</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#object-types-support">Object Types Support</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-manual/custom-properties-importing">Custom Properties for Importing</a></li>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-manual/extending-the-importer">Extending The SuperTiled2Unity Importer</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#prefab-replacements">Prefab Replacements</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#custom-importers">Custom Importers</a></li>
</ul>
</li>
</ul>
</div>
            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="index.html#document-index">SuperTiled2Unity</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="index.html#document-index">Docs</a> &raquo;</li>
        
      <li>SuperTiled2Unity 1.0.0.0 documentation</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            
              <a href="https://github.com/Seanba/SuperTiled2Unity/blob/master/docs/index.rst" class="fa fa-github"> Edit on GitHub</a>
            
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="supertiled2unity-documentation">
<h1>SuperTiled2Unity Documentation<a class="headerlink" href="#supertiled2unity-documentation" title="Permalink to this headline">¶</a></h1>
<div class="figure" id="id1">
<img alt="Mega Dad (aka Sean Barton)" src="_images/mega-dad-stand.png" />
<p class="caption"><span class="caption-text">By <a class="reference external" href="http://www.seanba.com">Sean Barton</a></span></p>
</div>
<p><strong>SuperTiled2Unity</strong> is a collection of Unity scripts that import files from the popular <a class="reference external" href="https://www.mapeditor.org/">Tiled Map Editor</a> in your Unity projects.</p>
<p>The goal of SuperTiled2Unity is that <strong>it just works</strong>. Except for the most specialized cases users should be able to quickly and easily add tile-based 2D content to their Unity projects.</p>
<p>SuperTiled2Unity is currently distibuted as a Unity Package at any price you choose (including free).
Additional <a class="reference external" href="http://www.seanba.com/donate">donations can be made</a> and <strong>are always appreciated</strong>.</p>
<div class="figure">
<img alt="_images/unity-super-metroid.png" src="_images/unity-super-metroid.png" />
</div>
<div class="toctree-wrapper compound">
<span id="document-manual/sorting"></span><div class="section" id="sorting-with-supertile2unity">
<h2>Sorting with SuperTile2Unity<a class="headerlink" href="#sorting-with-supertile2unity" title="Permalink to this headline">¶</a></h2>
<p>At the map import level, SuperTiled2Unity has two options for sorting the layers (and objects) in your <a class="reference external" href="https://www.mapeditor.org/">Tiled Map Editor</a> file.</p>
<div class="figure">
<img alt="_images/sorting-options.png" src="_images/sorting-options.png" />
</div>
<p><strong>Sorting Modes</strong></p>
<table border="1" class="colwidths-auto docutils">
<tbody valign="top">
<tr class="row-odd"><td>Stacked</td>
<td>Default sorting. Matches the rendering order of layers and objects in Tiled.</td>
</tr>
<tr class="row-even"><td>Custom Sort Axis</td>
<td>Sorting is performed with the help of a Custom Sort Axis (a setting in Unity).</td>
</tr>
</tbody>
</table>
<p><code class="code docutils literal notranslate"><span class="pre">Stacked</span></code> is a good default for side-scroller games where players and other game objects do not move about the map in ways that change their rendering order.
Overhead-style games may prefer to use the <code class="code docutils literal notranslate"><span class="pre">Custom</span> <span class="pre">Sort</span> <span class="pre">Axis</span></code> setting.
This takes a little more work but will be necessary if you need the rendering order of game objets against tiles to be dynamic.</p>
<div class="figure" id="id1">
<img alt="_images/example-sorting.png" src="_images/example-sorting.png" />
<p class="caption"><span class="caption-text">The example that comes with SuperTiled2Unity uses a Custom Sort Axis so that our player can be rendered either in front of or behind these columns depending on his current y-position.</span></p>
</div>
<div class="section" id="how-supertiled2unity-implements-sorting">
<h3>How SuperTiled2Unity Implements Sorting<a class="headerlink" href="#how-supertiled2unity-implements-sorting" title="Permalink to this headline">¶</a></h3>
<p>In Unity, render order of sprite and tile assets is generally handled through two settings on the <a class="reference external" href="https://docs.unity3d.com/Manual/class-SpriteRenderer.html">Sprite Renderer</a>
and <a class="reference external" href="https://docs.unity3d.com/Manual/class-TilemapRenderer.html">Tilemap Renderer</a> components:</p>
<table border="1" class="colwidths-auto docutils">
<tbody valign="top">
<tr class="row-odd"><td>Sorting Layer</td>
<td>Name of sorting layer. See the <a class="reference external" href="https://docs.unity3d.com/Manual/class-TagManager.html">Tag Manager</a> to manage these.</td>
</tr>
<tr class="row-even"><td>Order in Layer</td>
<td>How the renderer is sorted in the named layer.</td>
</tr>
</tbody>
</table>
<p>SuperTiled2Unity performs sorting almost primarily through manipulating the <code class="code docutils literal notranslate"><span class="pre">Order</span> <span class="pre">in</span> <span class="pre">Layer</span></code> setting of the prefab components it creates during import.
By default, all tile layers use the Unity’s built-in <code class="code docutils literal notranslate"><span class="pre">Default</span></code> sorting layer with ever increasing <code class="code docutils literal notranslate"><span class="pre">Order</span> <span class="pre">in</span> <span class="pre">Layer</span></code> values.</p>
<div class="figure" id="id2">
<img alt="_images/default-sorting.png" src="_images/default-sorting.png" />
<p class="caption"><span class="caption-text">Higher layers in Tiled use higher <code class="code docutils literal notranslate"><span class="pre">Order</span> <span class="pre">in</span> <span class="pre">Layer</span></code> values in Unity so that rendering order is preserved.</span></p>
</div>
<p>Most Unity projects, however, will have several custom <code class="code docutils literal notranslate"><span class="pre">Sorting</span> <span class="pre">Layers</span></code> that we want a mix of tiles and sprites to share.
In these cases, a specifically-named custom property, <code class="code docutils literal notranslate"><span class="pre">unity:SortingLayer</span></code>, will direct SuperTiled2Unity further on how sorting fields are assigned.</p>
<div class="figure">
<img alt="_images/tagman-sort-player.png" src="_images/tagman-sort-player.png" />
</div>
<div class="figure">
<img alt="_images/tiled-custom-prop-player.png" src="_images/tiled-custom-prop-player.png" />
</div>
<p>This will result in our <code class="code docutils literal notranslate"><span class="pre">Objects</span></code> tile layer breaking the chain of <code class="code docutils literal notranslate"><span class="pre">Default</span></code> sorting layers.</p>
<div class="figure">
<img alt="_images/default-player-sorting.png" src="_images/default-player-sorting.png" />
</div>
<p>Note that the <code class="code docutils literal notranslate"><span class="pre">Clouds</span></code> layer will still be rendered on top of the <code class="code docutils literal notranslate"><span class="pre">Objects</span></code> layer.
You may wish to use yet another <code class="code docutils literal notranslate"><span class="pre">unity:SortingLayer</span></code> for clouds to make it more explicit that these tiles are drawn on top of other tiles and sprites.</p>
<div class="figure">
<img alt="_images/tiled-custom-prop-sky.png" src="_images/tiled-custom-prop-sky.png" />
</div>
<p>Now the cloud tiles will be rendered in order but on a sorting layer that is more aptly named for them and other tiles that may always appear above our map.</p>
<div class="figure">
<img alt="_images/default-player-sky-sorting.png" src="_images/default-player-sky-sorting.png" />
</div>
<div class="admonition tip">
<p class="first admonition-title">Tip</p>
<p class="last">It takes a bit of work but in general it is a good idea to be explicit about what layers (in Tiled) are assigned to which sort layer (in Unity).
Using the <code class="code docutils literal notranslate"><span class="pre">unity:SortingLayer</span></code> in concert with Unity Sorting Layers <em>early</em> makes it easier to make sweeping sorting changes <em>later</em>.</p>
</div>
</div>
<div class="section" id="tile-objects-and-sorting">
<h3>Tile Objects and Sorting<a class="headerlink" href="#tile-objects-and-sorting" title="Permalink to this headline">¶</a></h3>
<p>Tiled allows you to place tiles in a an <a class="reference external" href="http://doc.mapeditor.org/en/stable/manual/layers/#object-layers">object layer</a> as separate tile objects.
During import, Tiled2Unity turns these tile objects into sprites that are not part of any <code class="code docutils literal notranslate"><span class="pre">Tilemap</span></code>.
If you import your map with the <code class="code docutils literal notranslate"><span class="pre">Stacked</span></code> sorting mode then these sprites will also be assigned a sort order.</p>
<div class="figure">
<img alt="_images/sort-tile-objects.png" src="_images/sort-tile-objects.png" />
</div>
<p>This may make it difficult to predict what sorting order is assigned to the layer that comes after <code class="code docutils literal notranslate"><span class="pre">TileObjects</span></code> as it depends on the number of objects in that group.
Using a custom property to set the sorting layer name on the next layer will help.
(Note that for the <code class="code docutils literal notranslate"><span class="pre">Custom</span> <span class="pre">Sort</span> <span class="pre">Axis</span></code> sort mode that each imported sprite is not assigned an incrememted sorting order as they will be sorted by their y-position instead.)</p>
</div>
<div class="section" id="dynamic-sorting-with-a-custom-sort-axis">
<h3>Dynamic Sorting with a Custom Sort Axis<a class="headerlink" href="#dynamic-sorting-with-a-custom-sort-axis" title="Permalink to this headline">¶</a></h3>
<p>Games with an overhead view often have sprites that need to alter their rendering order with tile maps as they move around.
The classic example is a sprite that may appear either in-front-of or behind a column based on their y-position.</p>
<div class="figure" id="id3">
<img alt="_images/overhead-example-anim.gif" src="_images/overhead-example-anim.gif" />
<p class="caption"><span class="caption-text">The <code class="code docutils literal notranslate"><span class="pre">overhead</span></code> scene included with SuperTiled2Unity may serve as a useful guide for others trying to achieve this effect.</span></p>
</div>
<p>In order to use custom axis sorting follow these three steps:</p>
<ul class="simple">
<li>Import your map with the <code class="code docutils literal notranslate"><span class="pre">Custom</span> <span class="pre">Sort</span> <span class="pre">Axis</span></code> sort mode</li>
<li>Modify <code class="code docutils literal notranslate"><span class="pre">Transparency</span> <span class="pre">Sort</span> <span class="pre">Mode</span></code> and <code class="code docutils literal notranslate"><span class="pre">Transparency</span> <span class="pre">Sort</span> <span class="pre">Axis</span></code> in your Unity Project Settings to sort against an axis with increasing y-value.</li>
<li>Make sure your sprites (Unity) and tiles (Tiled) <em>that you want to sort dynamically</em> are assigned the same <code class="code docutils literal notranslate"><span class="pre">Sorting</span> <span class="pre">Layer</span></code> and <code class="code docutils literal notranslate"><span class="pre">Order</span> <span class="pre">in</span> <span class="pre">Layer</span></code> values. (This is the most common source of errors.)</li>
</ul>
<div class="figure">
<img alt="_images/unity-importer-csa.png" src="_images/unity-importer-csa.png" />
</div>
<div class="figure">
<img alt="_images/unity-settings-csa.png" src="_images/unity-settings-csa.png" />
</div>
<div class="admonition tip">
<p class="first admonition-title">Tip</p>
<p class="last">Objects to be dynamically sorted by a Custom Sort Axis will need to have the same <code class="code docutils literal notranslate"><span class="pre">Sorting</span> <span class="pre">Layer</span></code> and <code class="code docutils literal notranslate"><span class="pre">Order</span> <span class="pre">in</span> <span class="pre">Layer</span></code> values of the tiles they are sorting against.</p>
</div>
<p>Note that you can also set the <code class="code docutils literal notranslate"><span class="pre">Transparency</span> <span class="pre">Sort</span> <span class="pre">Axis</span></code> in script if you wish.</p>
<div class="code C# highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">var</span> <span class="n">camera</span> <span class="o">=</span> <span class="n">GameObject</span><span class="o">.</span><span class="n">FindGameObjectWithTag</span><span class="p">(</span><span class="s2">&quot;MainCamera&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">GetComponent</span><span class="o">&lt;</span><span class="n">Camera</span><span class="o">&gt;</span><span class="p">();</span>
<span class="n">camera</span><span class="o">.</span><span class="n">transparencySortMode</span> <span class="o">=</span> <span class="n">TransparencySortMode</span><span class="o">.</span><span class="n">CustomAxis</span><span class="p">;</span>
<span class="n">camera</span><span class="o">.</span><span class="n">transparencySortAxis</span> <span class="o">=</span> <span class="n">Vector3</span><span class="o">.</span><span class="n">up</span><span class="p">;</span>
</pre></div>
</div>
</div>
</div>
<span id="document-manual/custom-properties"></span><div class="section" id="custom-properties-support">
<h2>Custom Properties Support<a class="headerlink" href="#custom-properties-support" title="Permalink to this headline">¶</a></h2>
<p>The <a class="reference external" href="https://www.mapeditor.org/">Tiled Map Editor</a> has support for <a class="reference external" href="http://doc.mapeditor.org/en/stable/manual/custom-properties/">Custom Properties</a>
that allow you to include custom data or information along with components of your map.</p>
<div class="figure" id="id1">
<img alt="Custom Properties in Tiled" src="_images/props-tiled.png" />
<p class="caption"><span class="caption-text">Tiled Custom Properties</span></p>
</div>
<p>These custom properties are also <strong>supported by SuperTiled2Unity</strong> and can be found on the <code class="code docutils literal notranslate"><span class="pre">SuperCustomProperties</span></code> Monobehaviour component when imported in your Unity project.</p>
<div class="figure" id="id2">
<img alt="Custom Properties in Unity" src="_images/props-unity.png" />
<p class="caption"><span class="caption-text">SuperTiled2Unity Custom Properties</span></p>
</div>
<div class="section" id="object-types-support">
<h3>Object Types Support<a class="headerlink" href="#object-types-support" title="Permalink to this headline">¶</a></h3>
<p>Tiled also has <em>predefined</em> properties that are described through the
<a class="reference external" href="http://doc.mapeditor.org/en/stable/manual/custom-properties/?highlight=object%20type#predefining-properties">Object Types Editor</a>.</p>
<div class="figure" id="id3">
<img alt="Object Types Editor" src="_images/object-types-editor.png" />
<p class="caption"><span class="caption-text">Object Types Editor</span></p>
</div>
<p>This is a time-saving way to create classes or groups of properties. However, by default, SuperTiled2Unity has no way of being aware of these predefined properties.
This can be resolved by <strong>exporting the Object Types Xml file</strong> to your Unity project.</p>
<p>First, select <code class="code docutils literal notranslate"><span class="pre">Export</span> <span class="pre">Object</span> <span class="pre">Types...</span></code> from the <code class="code docutils literal notranslate"><span class="pre">File</span></code> menu item.</p>
<div class="figure" id="id4">
<img alt="Export Object Types Xml" src="_images/export-objects-types.png" />
<p class="caption"><span class="caption-text">Select <strong>Export Object Types</strong> from the File menu item</span></p>
</div>
<p>This will bring up the save file dialog. Save your object types Xml file somewhere within your Unity project.</p>
<div class="figure" id="id5">
<img alt="Save Dialog" src="_images/export-save-dialog.png" />
<p class="caption"><span class="caption-text">Save Object Types Xml file to your Unity Project</span></p>
</div>
<div class="admonition tip">
<p class="first admonition-title">Tip</p>
<p class="last">You can export your Object Types Xml file to any filename but make sure it is somewhere under your Unity project’s <code class="code docutils literal notranslate"><span class="pre">Assets</span></code> directory.
This Xml file itself will need to be a Unity asset that is referenced by SuperTiled2Unity’s settings.</p>
</div>
<p>We now need to make SuperTiled2Unity aware of this exported Object Types Xml file through the <code class="code docutils literal notranslate"><span class="pre">SuperTiled2Unity</span> <span class="pre">Project</span> <span class="pre">Settings</span></code>.
These settings are found with your other project-wide settings (audio, graphics, etc.) through the <code class="code docutils literal notranslate"><span class="pre">Edit</span> <span class="pre">-&gt;</span> <span class="pre">Project</span> <span class="pre">Settings...</span></code> menu item.</p>
<div class="figure">
<img alt="_images/unity-projects-settings-menuitem.png" src="_images/unity-projects-settings-menuitem.png" />
</div>
<p>In the settings window you should see a field for <code class="code docutils literal notranslate"><span class="pre">Object</span> <span class="pre">Types</span> <span class="pre">Xml</span></code>. Either drag and drop your recently exported Object Types Xml filed into this field or use the
asset selector button to select the asset.</p>
<div class="figure" id="id6">
<img alt="SuperTiled2Unity Project Settings" src="_images/st2u-project-settings-object-xml.png" />
<p class="caption"><span class="caption-text">Drag and drop your exported object types Xml file into the <strong>Object Types Xml</strong> field</span></p>
</div>
<p>With the Object Types Xml file now set hit the <code class="code docutils literal notranslate"><span class="pre">View</span> <span class="pre">Custom</span> <span class="pre">Properties</span></code> button just below.
This will display the <code class="code docutils literal notranslate"><span class="pre">Custom</span> <span class="pre">Object</span> <span class="pre">Types</span> <span class="pre">Properties</span></code> window which lists all the custom object types that were imported as well as their custom properties (if any) and custom color.</p>
<div class="figure" id="id7">
<img alt="Custom Object Types Properties" src="_images/custom-object-types-window.png" />
<p class="caption"><span class="caption-text">Custom properties for object types are displayed in this window.</span></p>
</div>
<p>Now, any in your Unity project that are updated should have these predefined properties in the appropriate <code class="code docutils literal notranslate"><span class="pre">SuperCustomProperties</span></code> instances.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">Note that SuperTiled2Unity does not automatically update map assets when changes to the Object Types Xml are made.
See the <code class="code docutils literal notranslate"><span class="pre">Reimport</span> <span class="pre">Tiled</span> <span class="pre">Assets</span></code> button in the <code class="code docutils literal notranslate"><span class="pre">SuperTiled2Unity</span> <span class="pre">Project</span> <span class="pre">Settings</span></code> inspector if you want to update all Tiled assets in your Unity project.
<strong>This may take some time</strong> depending on the number and complexity of your Tiled assets, however.</p>
</div>
</div>
</div>
<span id="document-manual/custom-properties-importing"></span><div class="section" id="custom-properties-for-importing">
<h2>Custom Properties for Importing<a class="headerlink" href="#custom-properties-for-importing" title="Permalink to this headline">¶</a></h2>
<img alt="_images/custom-prop-ignore.png" src="_images/custom-prop-ignore.png" />
<p>You can customize how some portions of your Tiled files are imported into Unity prefabs through special custom properties.
These custom properties always have a <code class="code docutils literal notranslate"><span class="pre">unity:</span></code> prefix so that they do not collide with your own custom properties.</p>
<table border="1" class="colwidths-auto docutils">
<thead valign="bottom">
<tr class="row-odd"><th class="head">Property Name</th>
<th class="head">Value Type</th>
<th class="head">Used On</th>
<th class="head">Purpose</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="code docutils literal notranslate"><span class="pre">unity:ignore</span></code></td>
<td><code class="code docutils literal notranslate"><span class="pre">string</span></code></td>
<td>Layers</td>
<td><p class="first">Portions of the Tiled layer can be ignored during the import process. This is useful if you tiles to appear for a layer but not the colliders, for instance.</p>
<dl class="last docutils">
<dt>Acceptable values:</dt>
<dd><ul class="first last simple">
<li><strong>False</strong>: The layer is imported in full (default)</li>
<li><strong>True</strong>: The layer is fully ignored (same result as having the layer invisible in Tiled)</li>
<li><strong>Visual</strong>: The tiles are not imported for the layer.</li>
<li><strong>Collision</strong>: The colliders are not imported for the layer.</li>
</ul>
</dd>
</dl>
</td>
</tr>
<tr class="row-odd"><td><code class="code docutils literal notranslate"><span class="pre">unity:IsTrigger</span></code></td>
<td><code class="code docutils literal notranslate"><span class="pre">bool</span></code></td>
<td>Layers, Tileset, Tile, Collider, Collider Group</td>
<td>Controls the <code class="code docutils literal notranslate"><span class="pre">isTrigger</span></code> setting of the <code class="code docutils literal notranslate"><span class="pre">Collider2D</span></code> object generated in the prefab. Add as a layer custom property to override all colliders for a given layer.</td>
</tr>
<tr class="row-even"><td><code class="code docutils literal notranslate"><span class="pre">unity:layer</span></code></td>
<td><code class="code docutils literal notranslate"><span class="pre">string</span></code></td>
<td>Layers, Tileset, Tile, Collider, Collider Group</td>
<td>Controls which Unity phyisics layer our generated colliders are assigned. The layer name must exist in your project’s Tag Manager.</td>
</tr>
<tr class="row-odd"><td><code class="code docutils literal notranslate"><span class="pre">unity:SortingLayer</span></code></td>
<td><code class="code docutils literal notranslate"><span class="pre">string</span></code></td>
<td>Layers, Tile Objects</td>
<td>Controls which sorting layer is assigned to the Unity <code class="code docutils literal notranslate"><span class="pre">Renderer</span></code> component created for your tilemaps and sprites. The sorting layer name must exist in your project’s Tag Manager.</td>
</tr>
<tr class="row-even"><td><code class="code docutils literal notranslate"><span class="pre">unity:SortingOrder</span></code></td>
<td><code class="code docutils literal notranslate"><span class="pre">int</span></code></td>
<td>Layers, Tile Objects</td>
<td>Controls which sorting order is applied to the Unity <code class="code docutils literal notranslate"><span class="pre">Renderer</span></code> component created for your tilemaps and sprites.</td>
</tr>
<tr class="row-odd"><td><code class="code docutils literal notranslate"><span class="pre">unity:Tag</span></code></td>
<td><code class="code docutils literal notranslate"><span class="pre">string</span></code></td>
<td>Layers, Objects</td>
<td>Controls which tag is applied to the <code class="code docutils literal notranslate"><span class="pre">GameObject</span></code> created for your layers and objects. The tag must exist in your project’s Tag Manager.</td>
</tr>
</tbody>
</table>
</div>
<span id="document-manual/extending-the-importer"></span><div class="section" id="extending-the-supertiled2unity-importer">
<h2>Extending The SuperTiled2Unity Importer<a class="headerlink" href="#extending-the-supertiled2unity-importer" title="Permalink to this headline">¶</a></h2>
<img alt="_images/custom-importer-header.png" src="_images/custom-importer-header.png" />
<p><strong>SuperTiled2Unity</strong> strives to build prefabs out of your Tiled maps (*.txm files) with minimal input from users.
This is achieved  through <a class="reference external" href="https://docs.unity3d.com/Manual/ScriptedImporters.html">Scripted Importers</a> which was first added with Unity 2017.</p>
<p>Every game is different, however, and for projects of some complexity you’ll want to extend the SuperTiled2Unity import pipeline to fit your needs.</p>
<p>SuperTiled2Unity gives you two ways to modify generated prefabs. Once hooked up these modifications will become an itegral part of the import process.
This means the same modifications will applied to your maps, automatically, every time you resave in Tiled.</p>
<div class="admonition tip">
<p class="first admonition-title">Tip</p>
<p class="last">If you find you have to modify your imported Tiled maps by hand after every save then this is for you. Automating the pipeline saves you time and frustration.</p>
</div>
<dl class="docutils">
<dt>SuperTiled2Unity provides two ways to modify the import pipeline:</dt>
<dd><ul class="first last simple">
<li>Prefab Replacements</li>
<li>Custom Importers</li>
</ul>
</dd>
</dl>
<div class="section" id="prefab-replacements">
<h3>Prefab Replacements<a class="headerlink" href="#prefab-replacements" title="Permalink to this headline">¶</a></h3>
<p><strong>Prefab Replacements</strong> are the easiest way to modify your imported maps.
In essence, they replace a <code class="code docutils literal notranslate"><span class="pre">Tiled</span> <span class="pre">Object</span></code> in your map with a <code class="code docutils literal notranslate"><span class="pre">Prefab</span> <span class="pre">Instance</span></code> based on a prefab in your project.</p>
<p>This <a class="reference external" href="https://github.com/Seanba/SuperPrefabReplacement">Github Repo</a> explains Prefab Replacements in greater detail and provides a working example.</p>
<div class="admonition tip">
<p class="first admonition-title">Tip</p>
<p class="last"><strong>Prefab Replacements</strong> are ideal for spawners.
Also, any custom properties on your <code class="code docutils literal notranslate"><span class="pre">Tiled</span> <span class="pre">Object</span></code> with a name that matches a field in your prefab’s components will be automatically applied.</p>
</div>
</div>
<div class="section" id="custom-importers">
<h3>Custom Importers<a class="headerlink" href="#custom-importers" title="Permalink to this headline">¶</a></h3>
<p><strong>Custom Importers</strong> are the most powerful way to modify your imported prefabs.
They give you a place (in code) in the import process where you can completely transform the generated prefab.
This power does come at a cost though as it requires you to write some code.
This may be intimidating to people new to computer programming but if your project requires the kind of specialization affored by custom importers
then it is highly recommended you invest the time needed to up your coding skills.</p>
<div class="highlight-csharp notranslate"><div class="highlight"><pre><span></span><span class="c1">// The AutoCustomTmxImporterAttribute will force this importer to always be applied.</span>
<span class="c1">// Leave this attribute off if you want to choose a custom importer from a drop-down list instead.</span>
<span class="na">[AutoCustomTmxImporter()]</span>
 <span class="k">public</span> <span class="k">class</span> <span class="nc">MyTmxImporter</span> <span class="p">:</span> <span class="n">CustomTmxImporter</span>
 <span class="p">{</span>
     <span class="k">public</span> <span class="k">override</span> <span class="k">void</span> <span class="nf">TmxAssetImported</span><span class="p">(</span><span class="n">TmxAssetImportedArgs</span> <span class="n">args</span><span class="p">)</span>
     <span class="p">{</span>
         <span class="c1">// Note: args.ImportedSuperMap is the root of the imported prefab</span>
         <span class="c1">// You can modify the gameobjects and components any way you wish here</span>
         <span class="c1">// Howerver, the results must be deterministic (i.e. the same prefab is created each time)</span>
         <span class="kt">var</span> <span class="n">map</span> <span class="p">=</span> <span class="n">args</span><span class="p">.</span><span class="n">ImportedSuperMap</span><span class="p">;</span>
         <span class="n">Debug</span><span class="p">.</span><span class="n">LogFormat</span><span class="p">(</span><span class="s">&quot;Map &#39;{0}&#39; has been imported.&quot;</span><span class="p">,</span> <span class="n">map</span><span class="p">.</span><span class="n">name</span><span class="p">);</span>
     <span class="p">}</span>
 <span class="p">}</span>
</pre></div>
</div>
<p>This <a class="reference external" href="https://github.com/Seanba/SuperMovingPlatform">Github Repo</a> has a working example of a custom importer (named <code class="code docutils literal notranslate"><span class="pre">TrackCustomImporter</span></code>) in action.
It takes a specially-marked <code class="code docutils literal notranslate"><span class="pre">GameObject</span></code> and moves it along a track that was drawn in a Tiled map.</p>
<div class="admonition tip">
<p class="first admonition-title">Tip</p>
<p class="last"><strong>Custom Importers</strong> requires programming but they provide the ideal way to bend the import pipeline to your will.</p>
</div>
</div>
</div>
</div>
</div>


           </div>
           
          </div>
          <footer>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2019, Seanba
      
        <span class="commit">
          Revision <code>9667af4c</code>.
        </span>
      

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  

  <div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions">
    <span class="rst-current-version" data-toggle="rst-current-version">
      <span class="fa fa-book"> Read the Docs</span>
      v: latest
      <span class="fa fa-caret-down"></span>
    </span>
    <div class="rst-other-versions">
      <dl>
        <dt>Versions</dt>
        
          <dd><a href="/en/latest/">latest</a></dd>
        
      </dl>
      <dl>
        <dt>Downloads</dt>
        
          <dd><a href="//supertiled2unity.readthedocs.io/_/downloads/en/latest/pdf/">pdf</a></dd>
        
          <dd><a href="//supertiled2unity.readthedocs.io/_/downloads/en/latest/htmlzip/">html</a></dd>
        
          <dd><a href="//supertiled2unity.readthedocs.io/_/downloads/en/latest/epub/">epub</a></dd>
        
      </dl>
      <dl>
        <dt>On Read the Docs</dt>
          <dd>
            <a href="//readthedocs.org/projects/supertiled2unity/?fromdocs=supertiled2unity">Project Home</a>
          </dd>
          <dd>
            <a href="//readthedocs.org/builds/supertiled2unity/?fromdocs=supertiled2unity">Builds</a>
          </dd>
      </dl>
      <hr/>
      Free document hosting provided by <a href="http://www.readthedocs.org">Read the Docs</a>.

    </div>
  </div>



  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
   

</body>
</html>